package hos.net.soap.convert

import com.drake.net.exception.ConvertException
import hos.net.soap.SoapConvertUtils
import okhttp3.Response
import org.json.JSONException
import java.lang.reflect.Type

/**
 * <p>Title: ListMapConvert </p>
 * <p>Description:  </p>
 * <p>Company: www.mapuni.com </p>
 *
 * @author : 蔡俊峰
 * @date : 2024-04-09 20:26
 * @version : 1.0
 */
class ListMapConvert : ResponseConvert() {
    @Suppress("UNCHECKED_CAST")
    override fun <R> Response.parseResponse(succeed: Type): R? {
        val bodyString = body?.string() ?: return null
        try {
            return SoapConvertUtils.parse(bodyString) as R?
        } catch (e: JSONException) {
            throw ConvertException(this, message = "Map List Convert error")
        } finally {
        }
    }
}